package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsNoticeAnnouncement;
import com.ruoyi.system.domain.news.query.NewsNoticeAnnouncementQuery;
import com.ruoyi.system.domain.news.vo.NewsNoticeAnnouncementVo;
import com.ruoyi.system.domain.news.vo.NewsNoticeAnnouncementVo;
import com.ruoyi.system.mapper.news.NewsNoticeAnnouncementMapper;
import com.ruoyi.system.service.news.NewsNoticeAnnouncementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsNoticeAnnouncementServiceImpl extends ServiceImpl<NewsNoticeAnnouncementMapper, NewsNoticeAnnouncement>
        implements NewsNoticeAnnouncementService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsNoticeAnnouncementVo> getNewsNoticeAnnouncementList(NewsNoticeAnnouncementQuery newsNoticeAnnouncementQuery) {
        if (newsNoticeAnnouncementQuery.getIfPage()) {
            PageHelper.startPage(newsNoticeAnnouncementQuery.getPageNum(), newsNoticeAnnouncementQuery.getPageSize());
        }
        List<NewsNoticeAnnouncementVo> newsNoticeAnnouncementVoList = baseMapper.getNewsNoticeAnnouncementList(newsNoticeAnnouncementQuery);
        if (!newsNoticeAnnouncementVoList.isEmpty() && newsNoticeAnnouncementQuery.getId() == null) {
            for (NewsNoticeAnnouncementVo newsNoticeAnnouncementVo:newsNoticeAnnouncementVoList) {
                newsNoticeAnnouncementVo.setContent(null);
            }
        }
        return newsNoticeAnnouncementVoList;
    }
}
